package lang.enumeration.safe;

public class Season implements Comparable {
	public static final Season SPRING;
	public static final Season SUMMER;
	public static final Season FALL;
	public static final Season WINTER;
	private static final Season m_seasons[];
	static {
		SPRING = new Season("Spring");
		SUMMER = new Season("Summer");
		FALL = new Season("Fall");
		WINTER = new Season("Winter");
		m_seasons = (new Season[] { SPRING, SUMMER, FALL, WINTER });
	}

	public static Season valueOf(String s) {
		for (int i = 0; i < m_seasons.length; i++)
			if (m_seasons[i].Name().equals(s))
				return m_seasons[i];
		throw new IllegalArgumentException(s);
	}
	public static final Season[] values() {
		return m_seasons;
	}

	private final String m_name;
	private static int m_nextOrdinal = 0;
	private final int m_ordinal;
	
	private Season(String s) {
		m_ordinal = m_nextOrdinal++;
		m_name = s;
	}

	public String toString() {
		return m_name;
	}

	public String Name() {
		return m_name;
	}

	public int compareTo(Object obj) {
		return m_ordinal - ((Season) obj).m_ordinal;
	}
}
